<?php
require_once('calendar/classes/tc_calendar.php');
$_SESSION['action'] = "my_approved";
?>
<?php 
if(!isset($_REQUEST['page'])){
$list["a.Tile"]="DESC";
$list["a.Timecreate"]="DESC";
$list["a.IDApproveDoc"]="DESC";
$list["a.TimeApprove"]="DESC";
//$str=$_SESSION['sortn'];
//if($str==''){
$str="a.TimeApprove";
$_SESSION['sortn']=$str;
//}

$_SESSION['sort']=$list;
}else{
	$str=$_SESSION['sortn'];
	$list=$_SESSION['sort'];
}
$sql_library="select list_lable.IDLable,list_lable.LableName from list_lable where list_lable.IDEmployee='".$id_employee."'";
$mang_library=mysql_query($sql_library);
$query1  = mysql_query("SELECT IDEmployee,FullName FROM employee where State!=0");
$query_de = mysql_query("select department.IDDepartment, department_lang.DepartmentName from department, department_lang where department.IDDepartment = department_lang.IDDepartment and department_lang.LangID='"+$_SESSION['lang']+"'");

	
    if(array_key_exists("page",$_GET))
        $page  = $_GET['page'];
    else
        $page = 1;

    $abc = ($page-1)*10;
    
    if (isset($_REQUEST['search'])){
    	$tile=$_REQUEST['titleSearch'];
    	$fromdate=$_REQUEST['date1'];
    	$todate=$_REQUEST['date2'];
    	$search=$_REQUEST['search'];
    	
    	$sql="SELECT a.SumMoney,a.IDApproveDoc,e.FullName,a.Tile,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.IDTypeDoc,DATE_FORMAT(a.TimeApprove, '%Y-%m-%d') as DateApprove,a.isView  
								FROM approvedoc a,employee e 
								WHERE a.IDEmployee=e.IDEmployee and a.IDLabel<1 AND a.IDEmployee='$id_employee' AND a.IDStatus=1
									AND a.Tile LIKE '%$tile%' AND a.Timecreate>'".$fromdate." 00:00:00' AND a.Timecreate<'".$todate." 23:59:59'";
    	$query= mysql_query($sql." ORDER BY ".$str." ".$list[$str]);
    	$number_of_page = ceil ( mysql_num_rows( $query ) / $rows_per_page ); 
    }
    else {
    	$tile="";
    	$fromdate=date("Y-m-d"); 
   		$todate=date("Y-m-d"); 
   		
   		$sql="SELECT a.SumMoney,a.IDApproveDoc,e.FullName,a.Tile,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.IDTypeDoc,DATE_FORMAT(a.TimeApprove, '%Y-%m-%d') as DateApprove,a.isView  
								FROM approvedoc a,employee e 
								WHERE a.IDEmployee=e.IDEmployee  and a.IDLabel<1 AND a.IDEmployee='$id_employee' AND a.IDStatus=1 ";
    	$query= mysql_query($sql." ORDER BY ".$str." ".$list[$str]);
    	
    	$number_of_page = ceil ( mysql_num_rows( $query ) / $rows_per_page );     	
    }
   // echo $sql." ORDER BY ".$str." ".$list[$str];
?>

<script type="text/javascript">
function sort(page,str,co,search,tile,from,to)
{
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
												var body = document.getElementById('content');
												body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
												
												var d=document.createElement('div');
												d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
												
												var image=document.createElement('img');
												image.setAttribute('src','images/loading1.gif');
												image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
												
												d.appendChild(image);
												
											    body.appendChild(d);	
											    
											  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											    	document.getElementById("content").innerHTML=xmlhttp.responseText;
											    	document.getElementById('content').setAttribute('style','opacity:1; position:relative;');
											  }
									  }
	xmlhttp.open("GET","ajax/list/sort_my_approved.php?page="+page+"&str="+str+"&co="+co+"&search="+encodeURI(search)+"&titleSearch="+tile+"&date1="+from+"&date2="+to,true);
	xmlhttp.send();
}
function addLable(lang,idem,flagaction,search,tile,from,to,idsend)
{
	var newname=document.getElementById("vlNameLabel").value;
	if (newname=="") { alert("Null rồi"); return;}
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("liview").innerHTML=xmlhttp.responseText;
										    	$.ajax({url:"ajax/list/move_menu_left_library.php?lang="+lang+"&idem="+idem,success:function(result){
													//alert(result);
													$("#idlistLi").html(result);
											    }});
										  }
									  }
	xmlhttp.open("GET","ajax/process_li_listvb.php?search="+search+"&IDEmployeeSend="+idsend+"&titleSearch="+tile+"&date1="+from+"&date2="+to+"&flagaction="+flagaction+"&lablename="+newname,true);
	xmlhttp.send();
}

 
</script>
<style>
<!--
* {margin:0;}
-->
</style>
<link href="css/popup.css" rel="stylesheet" type="text/css" />
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script src="js/css-pop.js" type="text/javascript"></script>
<script type="text/javascript" src="js/dom-drag.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#content_menu_expand').hide();
		$(document).click(function() {
			$("#content_menu_expand").hide();
		});
		$('#content_menu_expand').click(function(e) {
			e.stopPropagation();
		});

		$('#menu_expand').click(function() {
			if ($('#content_menu_expand').is(":hidden")) {
				
				var listid="";
				$("input[id='chon']").each(function(){
					if (this.checked) listid = listid+","+this.value;
			    	})
				listid=listid.substr(1);	 
				if (listid=="") { alert("Bạn chưa chọn văn bản"); return;}
				$('#content_menu_expand').show();
				}
			else {
				$('#content_menu_expand').hide();
			}
			return false;
		});
		$('#close_menu').click(function() {
			$('#content_menu_expand').hide();
			return false;
		});

		$("ul.menu_inside li a").hover(function() {
			$(this).parent().find("ul.subnav").slideDown(0).show();
			$(this).parent().hover(function() {
			}, function(){
				$(this).parent().find("ul.subnav").slideUp(0);
			});
		}).hover(function() {
			$(this).addClass("subhover");
		}, function(){
			$(this).removeClass("subhover");
		});

	});		    
	function onprocessCheckbox(lang,idem,idli,search,tile,from,to,IdSend){
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
			    //alert(xmlhttp.responseText);
		        document.getElementById("content").innerHTML=xmlhttp.responseText;
		        $.ajax({url:"ajax/list/move_menu_left_library.php?lang="+lang+"&idem="+idem,success:function(result){
					//alert(result);
					$("#idlistLi").html(result);
			    }});
		        $.ajax({url:"ajax/list/move_list_changenumber.php?typeview=4&lang="+lang+"&idem="+idem,success:function(result1){
					$("#slmyapprove").html(result1);
			    }});
		        bindEventAfterAjax();
		    }
		  }
		var listid="";
		$("input[id='chon']").each(function(){
			if (this.checked) listid = listid+","+this.value;
	    	})
		listid=listid.substr(1);
		hoi= confirm("<?php echo $l_areyousure;?>");
		if (hoi==true) {
			xmlhttp.open("GET","ajax/list/move_my_approved.php?idli="+idli+"&search="+search+"&IDEmployeeSend="+IdSend+"&titleSearch="+tile+"&date1="+from+"&date2="+to+"&content=list-mydocument-approved-content&listid=" + listid,true);
			xmlhttp.send();
		}
		
		$('#content_menu_expand').hide();
		}

</script>
<script type="text/javascript">
function onclickButtonBackup(iduser){
	var listid="";
	$("input[id='chon']").each(function(){
		if (this.checked) listid = listid+","+this.value;
    	})
	listid=listid.substr(1);
	if (listid=="") { alert("<?=$l_choosedocbackup?>"); 
		return;
	}else{
		var lang = '<?=$_SESSION['lang']?>';
		$.ajax({url:"ajax/backup/backup_approve.php?iduser="+iduser+"&listid="+listid+"&newlang="+lang,success:function(result){
			closepopupss('root');
			 document.getElementById('content').innerHTML = result;
			alert("<?=$l_backupsuccessful?>");

			 $.ajax({url:"ajax/backup/update-menu-left.php?iduser="+iduser+"&newlang="+lang,success:function(result){
				 document.getElementById('slmyapprove').innerHTML = result;
				 }
			 });
			}
		});
	}
}
function onclickRestoreApprove(iduser){
	openpopupss('root');
	
	$.ajax({url:"ajax/backup/load-content-storebackup.php?iduser="+iduser,success:function(result){
		document.getElementById("handel_mo").innerHTML = result;
		
		}
	});
}

function processbuttonRadio(){
	var radioanswer = 'none'; var idapp="";
	if ($('input[name=radiolstfilebackup]:checked').val() != null) {           
	   radioanswer = $('input[name=radiolstfilebackup]:checked').val();
	   document.getElementById('idapp').value = $('input[name=radiolstfilebackup]:checked').val();
		document.getElementById('btrestore').setAttribute("class","inbtn");
		document.getElementById('btrestore').className = "inbtn";
		document.getElementById('btrestore').disabled = false;
	}else{
		document.getElementById('btrestore').setAttribute("class","inbtnDisable");
		document.getElementById('btrestore').className = "inbtn";
		document.getElementById('btrestore').disabled = true;
	}
}
function processButtonRestore(iduser){
		var radioanswer = document.getElementById('idapp').value;
		var lang = '<?=$_SESSION['lang']?>';
	 $.ajax({url:"ajax/backup/restore_approve.php",data:{iduser:iduser,radioanswer:radioanswer,newlang:lang},success:function(result){
		 closepopupss('root');
		 document.getElementById('content').innerHTML = result;
		 alert('<?=$l_restoresuccessful?>');

				 $.ajax({url:"ajax/backup/update-menu-left.php?iduser="+iduser+"&newlang="+lang,success:function(result){
					 document.getElementById('slmyapprove').innerHTML = result;
					 }
				 });
			}
		});

}
</script>
<style>
* {font-family:Arial, Helvetica, sans-serif; }
#fade { /*--Transparent background layer--*/
        display: none; /*--hidden by default--*/
        /*background: #000;*/
        position: fixed; left: 0; top: 0;
        width: 100%; height: 100%;
        opacity: .80;
        z-index: 9999;
}
.popup_block{
        display: none; /*--hidden by default--*/
        background: #fff;
        border: 1px solid silver;
        float: left;
        font-size: 1.2em;
        position: fixed;
        top: 50%; left: 50%;
        z-index: 99999;
        /*--CSS3 Box Shadows--*/
        /*--CSS3 Rounded Corners--*/
}
.btn_close {
        float: right;
        margin: 5px 5px 0 0;
		color:white;
		font-weight:bold;
}
/*--Making IE6 Understand Fixed Positioning--*/
*html #fade {
        position: absolute;
}
*html .popup_block {
        position: absolute;
}
.btnupbg {background:#309dcf; border-radius: 3px; color: white; cursor: pointer; font-weight: bold; height: 25px; padding: 0 5px 0 ;border-color: #C4C0B9; border-width: 1px; margin-right:5px}
.btnupbg:hover {background:#686868}
.btnupload {background: -moz-linear-gradient(center top , #63B6DB, #309DCF) repeat;}
</style>
<div class="title"></div>
                    <div class="content_code">
						<div class="approval-right">
							<form action="mydocument.php" method="get" id="mpform" name="mpform">
							<table width="100%" >
								<tr>
									<td>
										<div class="title_content"><?=$l_my_document ?> &rarr; <?=$l_approved_document ?></div>
											
											<input type="hidden" name="content" value="list-mydocument-approved-content" />
											<table border="1" bordercolor="#C5D1E8" cellpadding="4"  style="border-collapse:collapse">
												<tr height="40">
												<td align="center" style="vertical-align:middle;width: 120px"><?=$l_created_date?></td>
												<td align="center" style="height:24px;">
												<?php
												  $myCalendar1 = new tc_calendar("date1", true);
												  $myCalendar1->setIcon("calendar/images/iconCalendar.gif");
												  $d=split('-',$fromdate,3);
												 
												  $myCalendar1->setDate($d[2],$d[1],$d[0]);
												  $myCalendar1->setPath("calendar/");
												  $myCalendar1->setYearInterval(2010, 2015);
												  $myCalendar1->dateAllow('2010-01-01', '2015-12-31');
												  //$myCalendar1->setHeight(350);
												  //$myCalendar1->autoSubmit(true, "form1");
												  //$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
												  $myCalendar1->setOnChange("myChanged('test')");
												  //$myCalendar->rtl = true;
												  $myCalendar1->writeScript();
							
												  //echo $myCalendar1->getDate();
												  
												  ?>
												</td >
												
												  <td align="center" style="height:24px;">
												  <?php
												  $myCalendar2 = new tc_calendar("date2", true);
												  $myCalendar2->setIcon("calendar/images/iconCalendar.gif");
												  $d=split('-',$todate,3);
												 
												  $myCalendar2->setDate($d[2],$d[1],$d[0]);
												  $myCalendar2->setPath("calendar/");
												  $myCalendar2->setYearInterval(2010, 2015);
												  $myCalendar2->dateAllow('2010-01-01', '2015-12-31');
												  //$myCalendar1->setHeight(350);
												  //$myCalendar1->autoSubmit(true, "form1");
												  //$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
												  $myCalendar2->setOnChange("myChanged('test')");
												  //$myCalendar->rtl = true;
												  $myCalendar2->writeScript();
												  
												  ?>	
                   							  	<!--  >input type="hidden" name="totime" value="<?php echo $myCalendar2->getDate();?>" />
                   							  	<input type="hidden" name="fromtime" value="<?php echo $myCalendar1->getDate();?>" /-->
																
												</td>												
												</tr>
												
												<tr height="40">
												<td align="center" style="vertical-align:middle"><?=$l_title?> </td>
												<td colspan="2" style="padding-left: 3px;padding-right: 3px;">
													<input type="text" name="titleSearch" value="<?=$tile?>" style="width:600px;height:20px;" /></td>
												</tr>
											</table>	
												
																	
												
										</td>
								</tr>
								<tr>
									<td colspan="2" align="left">
										<table width="70%">
										<tr><td align="center">
											<input style="margin:12px 5px 0 0; font-size: 12px;" type="submit" value="<?=$l_search?>" class="btn_choose" name="search" />
											<input style="margin:12px 5px 0 0; font-size: 12px;" type="submit" name="all" value="<?=$l_all?>" class="btn_choose" />
										</td></tr></table>
									</td>
								
								</tr>
								<?php 
											    	$tile=$_REQUEST['titleSearch'];
											    	$fromdate=$_REQUEST['date1'];
											    	$todate=$_REQUEST['date2'];
											    	$search=$_REQUEST['search'];
													//page,str,co,search,tile,from,to,IdSend)
								?>
								<tr>
									<td>										
										<div style=" margin-top:30px" >
										<div style="position:relative; padding-bottom: 5px;">
											<input type="button" class="btnupbg btnupload"  name="Movevb" value="<?php echo $l_move;?>" id="menu_expand" />
										    <div id="content_menu_expand" class="passul">
										        <ul>
										            <li><a href="#?w=350" rel="popup_name" onclick="popuploadbel(this)" class="poplight"><?php echo $l_new_label?></a></li>
										        </ul>
										        <ul id="liview">
										            <?php 
													
														if(mysql_num_rows($mang_library)>0){
															while($row=mysql_fetch_array($mang_library)){
															?>
															<li><a  onclick="onprocessCheckbox('<?php echo $_SESSION['lang']?>','<?php echo $id_employee?>','<?php echo $row[IDLable]?>','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>');" ><?php echo $row[LableName]?></a></li>
															<?php 
															}
														}
													?>
										        </ul>
										    </div>
										    <input style="margin:12px 5px 0 0; font-size: 12px;" type="submit" name="updateMyApp" value="<?=$l_delete?>" class="btnupbg btnupload" />
										    <div style="float: right; padding-right: 0;">
										    <!-- 	<a href=""><b>
										    		<?php echo $l_backup;?>
										    		<?php 
										    			if(isset($_SESSION['listfileBK'])){
										    				echo " : "."ten file";
										    			}else{
										    				echo " : ...";
										    			}
										    		?>
										    		<?php echo " [ ".$l_download." ]";?></b>
										    	</a> -->
										    	<input style="margin:12px 5px 0 0; font-size: 12px;" type="button" name="bkbackup" value="<?=$l_backup?>" class="btnupbg btnupload" onclick="onclickButtonBackup('<?=$id_employee?>');"/>
										    	<input style="margin:12px 5px 0 0; font-size: 12px;" type="button" name="bkrestore" value="<?=$l_restore?>" class="btnupbg btnupload" onclick="onclickRestoreApprove('<?=$id_employee?>');"/>
										    </div>
										    
										</div>
										<div id="popup_name" class="popup_block">
											<span style="background:#424242;color: #FFFFFF; display: block;padding: 5px 0 5px 10px;"><?php echo $l_new_label;?> </span>
										    <table width="100%" style="margin:20px 0">
										    	<tr>
										    	<td width="15%"><b><?php echo $l_name;?></b></td>
										        <td valign="top"><input type="text" id="vlNameLabel" name="vlNameLabel" style="height:23px;width:95%; border:1px solid #ccc" size="35" maxlength="50" value="" /></td>
										        </tr>
										        <tr>
										        	<td></td>
										        	<td>
										        		<div align="center" style="padding-top: 3px;">
										        			<input type="button" class="btnupbg btnupload iclose" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;width:100px;float: right;margin-right: 13px;" value="<?php echo $l_cancel;?>" />
										    				<input type="button" onclick="addLable('<?php echo $_SESSION['lang'];?>','<?php echo $id_employee?>','newlb','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>');" style="float:right; font-family:Arial, Helvetica, sans-serif; font-size:12px;width:100px;float: right;" class="btnupbg btnupload iclose" value="<?php echo $l_create;?>" />
													    </div>
										        	</td>
										        </tr>
										    </table>
										</div>
										<div id="content">
											<table width="100%" class="table_th" style="height:22px;" cellspacing="0">
												
												<tr class="trtit" style="background-color:#EEE;">
													<td width="3%"><input type="checkbox" name="chonhetroi" id="chonhetroi" onclick="clickChonHetRoi(this);"/></td>
													<td width="3%"><?=$l_no?></td>
													<!--td width="10%"><a onclick="sort(<?=$page?>,'a.IDApproveDoc','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')">ID</a></td-->
										            <td width="15%"><?=$l_document_form?></td>
										            <td width="30%"><a onclick="sort(<?=$page?>,'a.Tile','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')"><?=$l_title?></a></td>
										 
										            <td width="10%"><a onclick="sort(<?=$page?>,'a.Timecreate','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')"><?=$l_created_date?></a></td>
										            <td width="10%"><a onclick="sort(<?=$page?>,'a.TimeApprove','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')"><?=$l_approve_date?></a></td>
										            <td width="5%"></td>
										         
										        </tr>
												
												<?php
												
											    $i = 0; 
											    while ($row=mysql_fetch_array($query)){
											    	if ( $i >= $page_start  ) 
													{	
												    	if($row[IDTypeDoc]==7)$document = $l_vacation_form;
													    else if($row[IDTypeDoc]==12)$document = $l_assignment_report;
													    else if($row[IDTypeDoc]==13)$document = $l_purchase_order;
													    else if($row[IDTypeDoc]==14)$document = $l_daily_report;
													    else if($row[IDTypeDoc]==15)$document = $l_business_trip_report;
													    else if($row[IDTypeDoc]==16)$document = $l_weekly_report;
													    else if($row[IDTypeDoc]==17)$document = $l_susqence_payment_request;
												    	else if($row['IDTypeDoc']==18)$document = $l_payment_request;
												    	else if($row[IDTypeDoc]==19)$document = $l_purchase_order1;
												?>
													<tr bgcolor="#ffffff" class="highlighter">
														<td><input type="checkbox" id="chon" name="xoa[]" value="<?=$row[IDApproveDoc]?>" /></td>
														<td width="3%" align="center"><?=($i+1)?></td>
														<!--td ><a href='mydocument.php?id=<?=$row[IDApproveDoc]?>&type=<?=$row[IDTypeDoc]?>&page=<?=$page?>'><?php echo $row[IDApproveDoc];?></a></td-->
														<td ><div  align="left" ><?php echo $document;?></div></td>
														<td >
															<div  align="left" >
																<a href='mydocument&<?=$row[IDApproveDoc]?>&<?=$row[IDTypeDoc]?>&<?=$page?>'><?=$row[Tile]?></a>
																
																
																<?php 
																//$today=strtotime('now');
																//$d=strtotime($row['DateApprove']);
																//if ($row['isView']==0 && ($today-$d)<=30*86400){
																if ($row['isView']==0){
																	echo "<span style='font-size:10px;'><span style='color: rgb(0, 0, 255); '><em>  [".$l_new."]</em></span></span>";
																}
																?>
																<p style="float:right">
															<?php 
																if($row[IDTypeDoc]==13 || $row[IDTypeDoc]==15 || $row[IDTypeDoc]==17 || $row[IDTypeDoc]==19){
																	if($row[SumMoney]>0){
																		echo " [ ".number_format($row[SumMoney])." ]";
																	}else{
																		if($row[IDTypeDoc]==15 || $row[IDTypeDoc]==13 || $row[IDTypeDoc]==19){
																			$s1="select sum(buying_document.total) as tongtien from approvedoc,buying_document where approvedoc.IDApproveDoc=buying_document.document_id and approvedoc.IDApproveDoc='".$row[IDApproveDoc]."' GROUP BY approvedoc.IDApproveDoc";
																			$k1=mysql_query($s1);
																			while ($r1=mysql_fetch_array($k1)){
																				if($r1[tongtien]>0){
																					echo " [ ".number_format($r1[tongtien])." ]";
																				}
																			}
																		}else if($row[IDTypeDoc]==17){
																			$s1="select sum(ap_advance.money) as tongtien from approvedoc,ap_advance where approvedoc.IDApproveDoc=ap_advance.document_id and approvedoc.IDApproveDoc='".$row[IDApproveDoc]."' GROUP BY approvedoc.IDApproveDoc";
																			$k1=mysql_query($s1);
																			while ($r1=mysql_fetch_array($k1)){
																				if($r1[tongtien]>0){
																					echo " [ ".number_format($r1[tongtien])." ]";
																				}
																			}
																		}
																	}
																}
															?>
															</p>
															</div>
															
														</td>
														<td ><?=$row[Timecreate]?></td>
														<td ><?=$row[DateApprove]?></td>
														<td><a href="newform-<?=$row[IDApproveDoc]?>&<?=$row[IDTypeDoc]?>&<?=$page?>&forward"><img src="images/edit-admin.png" /></a></td>
													</tr>
												<?php 	}
												
													$i++; 
													
													if ($i >= $page_end) 
													{ 
													break; 
													} 
												}
												
													
												?>
											
											<tr>
													<td colspan="7" class="bt_td_main">
													
													<span style="background:#fff; padding:1px; display: inline-block;">
														
														<?php if ( $number_of_page > 1 ) 
														{ 
															if ($page==1)
																$p=2;
															else if ($page==$number_of_page)
																$p=$number_of_page-1;
															else $p=$page;
															if($page!=1){?>
																<a onclick="sort(1,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')" ><span class='button_next'><?php echo "<<<";?></span> </a>
																<a onclick="sort(<?=($page-1)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')" ><span class='button_next'><?php echo "<<";?></span> </a>
															<?php  }
															else{
																echo "<span class='button_next'><<<</span>"; 
																echo "<span class='button_next'><<</span>";
															}
															for ( $i = $p-1; $i <= $p+1; $i++ ) {	
																	if ($i<=$number_of_page && $i>0)
																	
																		if ($i==$page){
																			echo "<span class='button_next'><b>".$i."</b></span>"; 
																		}else{
																		?>
																			<a onclick="sort(<?=$i?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')" ><span class="button_next" style="color: #508e21;">
																			<?php 
																			echo $i;
																			?>
																			</span> </a>
																		<?php 
																		}
																	?>
																
															<?php 
																	}
																
																if($page!=$number_of_page){ ?>
																	<a onclick="sort(<?=($page+1)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')"><span class='button_next'><?php echo ">>";?></span> </a>
																	<a onclick="sort(<?=($number_of_page)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>')" ><span class='button_next'><?php echo ">>>";?></span> </a>
																<?php }
																else{
																	echo "<span class='button_next'>>></span> ";
																	echo "<span class='button_next'>>>></span> ";
																}
															}
														
															
															?>
																												
													</span>
													</td>
												</tr>
											</table>
											</div>
										</div>
									</td>
								</tr>
							</table>
							</form>	
						</div>
					</div>
					
<div id="blanket" ></div>
	 <div id="popup_mo">
	 <form action="#" id="formCheck" name="formCheck">
		<div id="root" style="display:none;">
	    <div id="handle"><?php echo $l_lstfilebackup;?></div>
	    <div class="ptop">
	      <div id = "handel_mo" style="padding-top: 5px;">
	     
			    </div>
			</div>
				    <div class="pfoot" style="text-align: center;">
				     	<input type="button" class="inbtnDisable" value="Ok" style="vertical-align:middle" 
				     	onclick="processButtonRestore('<?=$id_employee?>');" name="btrestore" id="btrestore" disabled="disabled"/> 
				     	<input type="button" class="inbtn" value="Cancel" style="vertical-align:middle" 
				     	onclick="closepopupss('root');" name="btcancel" id="btcancel" /> 
				</div>
		</div>
	</form> 
	</div>
<script type="text/javascript">
	var theHandle = document.getElementById("handle");
	var theRoot   = document.getElementById("root");
	var theLoadImage = document.getElementById("loadimage");
	Drag.init(theHandle, theRoot);
	Drag.init(theLoadImage, theRoot);
</script>